package com.example.jsoup.config;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

/**
 * @Description 线程池配置
 * @Date 2020/7/17 15:15
 * @Author yule
 */
@Configuration
public class ExecutorServiceConfig {

    @Bean(name = "RedisExecutor")
    public ExecutorService httpclientExecutorService() {
        ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("redis-pool-%d").build();
        return new ThreadPoolExecutor(
                1,
                10,
                0L,
                TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<>(1024),
                namedThreadFactory,
                new ThreadPoolExecutor.AbortPolicy()
        );
    }
}
